package com.zzptc.gyc.yige;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    ListView listView; List<Student> list_stu;
    private static final String TAG = "MainActivity";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        listView=findViewById(R.id.lv);
        list_stu=new ArrayList<>();
        for(int i=0;i<100;i++){
            Student student= new Student(R.mipmap.ic_launcher,i,"姓名"+i,new Date()+"");
            list_stu.add(student);


        }
        for(Student s:list_stu){
            Log.d(TAG,s.getName());
        }
        MyAdapter myAdapter = new MyAdapter();
        listView.setAdapter(myAdapter);

    }
    class MyAdapter extends BaseAdapter{

        @Override
        public int getCount() {
            return 0;
        }

        @Override
        public Object getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            //要数据
            Student student = list_stu.get(position);
            View view1=   View.inflate(MainActivity.this,R.layout.item_stu,null);

            ImageView iv_pic = view1.findViewById(R.id.iv_pic);
            iv_pic.setImageResource(R.mipmap.ic_launcher);
            TextView iv_id=view1.findViewById(R.id.tv_id);
            iv_id.setText(student.getId()+"");
            TextView iv_name=view1.findViewById(R.id.tv_id);
            return null;
        }
    }
}